﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace MvcApplication1.Models
{
    public class LoginModel
    {
        [Required]
        [Display(Name="Login")]
        public string UserLogin { get; set; }

        [Required]
        [Display(Name = "Password")]
        public string Password { get; set; }


        [Display(Name = "Remember me?")]
        public bool RememberMe { get; set; }

        public bool IsValid(string _userlogin, string _passw)
        {

            var DataContext = new DataClassesDataContext();
            int UserLogOn = (from m in DataContext.Users where m.ULogin == _userlogin && m.UPassword== _passw  select  m.UserID).Single();
            if (UserLogOn>0)
            {
                return true;
            }
            else
                 return false;

        }
    }
}